home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / DELPHI32 / GRAPHICS / IMGLIB95 / IMGLIB95.ZIP / UBLOB.PA_ / UBLOB.PA
Text File  |  1996-04-01  |  28KB  |  902 lines

  1. {
  2. Written by Jan Dekkers and Kevin Adams (c) 1995, 1996. If you are a non
  3. registered client, you may use or alter this demo only for evaluation
  4. purposes.
  5.  
  6. Copyright by SkyLine Tools. All rights reserved.
  7.  
  8. Part of Imagelib VCL/DLL Library.
  9. }
  10.  
  11. unit Ublob;
  12.  
  13. {Includes settings to compile in either 16 or 32 bit}
  14. {$I DEFILIB.INC}
  15.  
  16. interface
  17.  
  18. uses
  19. {$IFDEF DEL32}
  20.   Windows,
  21. {$ELSE}
  22.   WinTypes,
  23.   WinProcs,
  24. {$ENDIF}
  25.   DLL95V1,    {ImageLib Dll interface and misc. functions}
  26.   SysUtils,
  27.   Messages,
  28.   Classes,
  29.   Graphics,
  30.   Controls,
  31.   Forms,
  32.   Dialogs,
  33.   DB,
  34.   DBTables,
  35.   StdCtrls,
  36.   ExtCtrls,
  37.   DBCtrls,
  38.   Gauges,
  39.   Mask,
  40.   Buttons,
  41.   Clipbrd,
  42.   Spin,
  43.   U_p_size,
  44.   Printers,
  45.   Ufullscr,
  46.   UAbout,
  47.   TDMULTIP,   {PDBMultiMedia1, PDBMultiImage VCL components}
  48.   Preview;
  49.  
  50.     
  51. type
  52.   TBlobForm1 = class(TForm)
  53.     Table1              : TTable;
  54.     DataSource1         : TDataSource;
  55.     DBNavigator1        : TDBNavigator;
  56.     Gauge1              : TGauge;
  57.     AutodisplayCheckBox : TCheckBox;
  58.     DBEdit1             : TDBEdit;
  59.     StretchCheckBox     : TCheckBox;
  60.     BitBtn1: TBitBtn;
  61.     OpenDialog1: TOpenDialog;
  62.     SaveDialog1: TSaveDialog;
  63.     BitBtn2: TBitBtn;
  64.     GroupBox1: TGroupBox;
  65.     RadioButton1: TRadioButton;
  66.     RadioButton2: TRadioButton;
  67.     RadioButton3: TRadioButton;
  68.     CenterCheckBox: TCheckBox;
  69.     BitBtn4: TBitBtn;
  70.     BitBtn5: TBitBtn;
  71.     Timer1: TTimer;
  72.     BitBtn6: TBitBtn;
  73.     Edit1: TEdit;
  74.     BitBtn3: TBitBtn;
  75.     OpenDialog2: TOpenDialog;
  76.     Edit2: TEdit;
  77.     Edit3: TEdit;
  78.     Edit4: TEdit;
  79.     Edit5: TEdit;
  80.     Edit6: TEdit;
  81.     Label1: TLabel;
  82.     Label2: TLabel;
  83.     Label3: TLabel;
  84.     Label4: TLabel;
  85.     Label5: TLabel;
  86.     Label6: TLabel;
  87.     Edit7: TEdit;
  88.     Label7: TLabel;
  89.     Edit8: TEdit;
  90.     GroupBox2: TGroupBox;
  91.     RadioButton4: TRadioButton;
  92.     RadioButton5: TRadioButton;
  93.     BitBtn7: TBitBtn;
  94.     BitBtn8: TBitBtn;
  95.     SaveDialog2: TSaveDialog;
  96.     GroupBox3: TGroupBox;
  97.     SpinEdit1: TSpinEdit;
  98.     SpinEdit2: TSpinEdit;
  99.     Label8: TLabel;
  100.     Label9: TLabel;
  101.     BitBtn9: TBitBtn;
  102.     PrintDialog1: TPrintDialog;
  103.     BitBtn11: TBitBtn;
  104.     BitBtn12: TBitBtn;
  105.     BitBtn13: TBitBtn;
  106.     RadioButton6: TRadioButton;
  107.     RadioButton7: TRadioButton;
  108.     RadioButton9: TRadioButton;
  109.     BitBtn14: TBitBtn;
  110.     BitBtn15: TBitBtn;
  111.     BitBtn16: TBitBtn;
  112.     BitBtn10: TBitBtn;
  113.     DBMultiImage1: TPDBMultiImage;
  114.     resAuto: TRadioButton;
  115.     StretchRatioCheckBox: TCheckBox;
  116.     RotateImageBtn: TBitBtn;
  117.     FlipImagetBtn: TBitBtn;
  118.     BitBtn17: TBitBtn;
  119.     BitBtn18: TBitBtn;
  120.     BitBtn19: TBitBtn;
  121.     RadioButton8: TRadioButton;
  122.     BitBtn20: TBitBtn;
  123.     BitBtn21: TBitBtn;
  124.     ThumbPreview1: TThumbPreview;
  125.     procedure FormCreate(Sender: TObject);
  126.     procedure AutodisplayCheckBoxClick(Sender: TObject);
  127.     procedure StretchCheckBoxClick(Sender: TObject);
  128.     procedure DataSource1DataChange(Sender: TObject; Field: TField);
  129.     procedure BitBtn1Click(Sender: TObject);
  130.     procedure BitBtn2Click(Sender: TObject);
  131.     procedure ResolutionClick(Sender: TObject);
  132.     procedure CenterCheckBoxClick(Sender: TObject);
  133.     procedure BitBtn4Click(Sender: TObject);
  134.     procedure BitBtn5Click(Sender: TObject);
  135.     procedure Timer1Timer(Sender: TObject);
  136.     procedure BitBtn6Click(Sender: TObject);
  137.     procedure BitBtn3Click(Sender: TObject);
  138.     procedure RadioButton4Click(Sender: TObject);
  139.     procedure BitBtn7Click(Sender: TObject);
  140.     procedure BitBtn8Click(Sender: TObject);
  141.     procedure SpinEdit2Change(Sender: TObject);
  142.     procedure SpinEdit1Change(Sender: TObject);
  143.     procedure BitBtn9Click(Sender: TObject);
  144.     procedure BitBtn11Click(Sender: TObject);
  145.     procedure BitBtn12Click(Sender: TObject);
  146.     procedure BitBtn13Click(Sender: TObject);
  147.     procedure RadioButton5Click(Sender: TObject);
  148.     procedure RadioButton6Click(Sender: TObject);
  149.     procedure RadioButton7Click(Sender: TObject);
  150.     procedure RadioButton9Click(Sender: TObject);
  151.     procedure BitBtn14Click(Sender: TObject);
  152.     procedure BitBtn15Click(Sender: TObject);
  153.     procedure BitBtn16Click(Sender: TObject);
  154.     procedure BitBtn10Click(Sender: TObject);
  155.     procedure StretchRatioCheckBoxClick(Sender: TObject);
  156.     procedure RotateImageBtnClick(Sender: TObject);
  157.     procedure FlipImagetBtnClick(Sender: TObject);
  158.     procedure BitBtn19Click(Sender: TObject);
  159.     procedure BitBtn17Click(Sender: TObject);
  160.     procedure BitBtn18Click(Sender: TObject);
  161.     procedure RadioButton8Click(Sender: TObject);
  162.     procedure BitBtn20Click(Sender: TObject);
  163.     procedure BitBtn21Click(Sender: TObject);
  164.     procedure DBMultiImage1MouseDown(Sender: TObject; Button: TMouseButton;
  165.       Shift: TShiftState; X, Y: Integer);
  166.     procedure DBMultiImage1MouseMove(Sender: TObject; Shift: TShiftState;
  167.       X, Y: Integer);
  168.     procedure DBMultiImage1MouseUp(Sender: TObject; Button: TMouseButton;
  169.       Shift: TShiftState; X, Y: Integer);
  170.     procedure DBNavigator1Click(Sender: TObject; Button: TNavigateBtn);
  171.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  172.   private
  173.     { Private declarations }
  174.     Procedure Trigger(Sender : TObject; Var Done : Boolean);
  175.   public
  176.     { Public declarations }
  177.     pointStart: TPoint;
  178.     pointEnd  : TPoint;
  179.     bLeftDown : boolean;
  180.     procedure DrawRubberband;
  181.   end;
  182.  
  183. var
  184.   BlobForm1: TBlobForm1;
  185.  
  186. implementation
  187.  
  188. {IMPORTANT}
  189. {Changed in version 2.21 from a procedure to a function with cdecl.
  190.  To cancel return a 0 else return a 1}
  191.  
  192. Function CallMe(i : integer) : integer; cdecl; export;
  193. {Callback function from the dll, CDECL and EXPORT ARE REQUIRED}
  194.  
  195. begin
  196.  if Application.Terminated then begin
  197.    {User wants to terminate the program. Pass a 0 to the dll}
  198.    Result:=0;
  199.   end else begin
  200.   {Be nice to others <g>}
  201.    Application.ProcessMessages;
  202.    {process a Gauge}
  203.    if BlobForm1 <> nil then
  204.     BlobForm1.Gauge1.Progress:=i;
  205.    {tell the dll that everything is OK}
  206.    Result:=1;
  207.    end;
  208. end;
  209. {---------------------------------------------------------------------}
  210.  
  211. {$R *.DFM}
  212. procedure TBlobForm1.FormCreate(Sender: TObject);
  213. begin
  214.  
  215.  Printersize:=TPrintersize.Create(Application);
  216.  
  217.  {Assign a callback function to the VCL/DLL}
  218.  TPDBMultiImageCallBack:=CallMe;
  219.  {Is Autodisplay Initial on or off}
  220.  DBMultiImage1.AutoDisPlay:=AutodisplayCheckBox.Checked;
  221.  {If the image data is changed save the blob to a jpeg or Bmp blob}
  222.  DBMultiImage1.UpdateAsJpg:=RadioButton4.Checked;
  223.  
  224.  {set the values of teh spin edit controls to the values of the vcl}
  225.  SpinEdit2.Value:=DBMultiImage1.JPegSaveSmooth;
  226.  SpinEdit1.Value:=DBMultiImage1.JPegSaveQuality;
  227.  
  228.  If FileExists(ExtractFilePath(Application.ExeName)+'JPSTAMP.DBF') then begin
  229.    {if the table exists open it on creation}
  230.    Table1.DataBaseName:=ExtractFilePath(Application.ExeName);
  231.    Table1.TableName:='JPSTAMP.DBF';
  232.    Table1.Active:=True;
  233.    {Table1.Last;}
  234.  end;
  235.  
  236.  
  237.  {IMPORTANT
  238.  This is the moving engine for all the messages. Since an applcation
  239.  can have only one OnIdle Trigger, this trigger needs to be subdivided
  240.    by all your moving and animated objects. In this particular case the
  241.  function is called TRIGGER but you can name it as you want as long
  242.  you have a procedure named the same.}
  243.  
  244.   Application.OnIdle:=Trigger;
  245. end;
  246. {---------------------------------------------------------------------}
  247.  
  248. Procedure TBlobForm1.Trigger(Sender : TObject; Var Done : Boolean);
  249. begin
  250.  {IMPORTANT}
  251.  {This function is called when your app is idle. Subdivide the
  252.   trigger event to your TDBMultiImage objects who may need one.
  253.   If no Message is active it will not take up significant time}
  254.  
  255.   DBMultiImage1.Trigger;
  256. end;
  257. {---------------------------------------------------------------------}
  258.  
  259. procedure TBlobForm1.AutodisplayCheckBoxClick(Sender: TObject);
  260. begin
  261.   {Toggle Autodisplay}
  262.   DBMultiImage1.AutoDisPlay:=AutodisplayCheckBox.Checked;
  263.  
  264.   {Let users know to double click when autodisplay is off}
  265.   DBMultiImage1.ShowHint:= not AutodisplayCheckBox.Checked;
  266.  
  267.   {reset the gauge to 0}
  268.   Gauge1.Progress:=0;
  269. end;
  270.  
  271. {---------------------------------------------------------------------}
  272. procedure TBlobForm1.StretchRatioCheckBoxClick(Sender: TObject);
  273. begin
  274.  {Stretch DBImage with ratio}
  275.  if StretchRatioCheckBox.Checked then begin
  276.     DBMultiImage1.Stretch:=false;
  277.     StretchCheckBox.Checked:=false;
  278.  end;
  279.  DBMultiImage1.StretchRatio:=StretchRatioCheckBox.Checked;
  280.  DBMultiImage1.Update;
  281. end;
  282. {---------------------------------------------------------------------}
  283.  
  284. procedure TBlobForm1.StretchCheckBoxClick(Sender: TObject);
  285. begin
  286.  {Stretch DBImage}
  287.  if StretchCheckBox.Checked then begin
  288.     DBMultiImage1.StretchRatio:=False;
  289.     StretchRatioCheckBox.Checked:=False;
  290.  end;
  291.  DBMultiImage1.Stretch:=StretchCheckBox.Checked;
  292.  DBMultiImage1.Update;
  293. end;
  294. {---------------------------------------------------------------------}
  295.  
  296. procedure TBlobForm1.CenterCheckBoxClick(Sender: TObject);
  297. begin
  298.  {Center DBImage}
  299.  DBMultiImage1.Center:=CenterCheckBox.Checked;
  300.  
  301.  {reset the gauge to 0}
  302.  Gauge1.Progress:=0;
  303. end;
  304. {---------------------------------------------------------------------}
  305.  
  306. procedure TBlobForm1.DataSource1DataChange(Sender: TObject; Field: TField);
  307. begin
  308.  {Reset the Gauge}
  309.   Gauge1.Progress:=0;
  310.  
  311.  {If DBMultiImage1.autodisplay = false then get the blob info
  312.   manually else the vcl will do it automatically}
  313.   If not DBMultiImage1.autodisplay then DBMultiImage1.GetInfoAndType;
  314.  
  315.  {Show the user the blob info}
  316.   Edit1.text:='This blob image is a '+DBMultiImage1.BFiletype;
  317.   Edit2.text:=IntToStr(DBMultiImage1.Bwidth);
  318.   Edit3.text:=IntToStr(DBMultiImage1.BHeight);
  319.   Edit4.text:=IntToStr(DBMultiImage1.Bbitspixel);
  320.   Edit5.text:=IntToStr(DBMultiImage1.Bplanes);
  321.   Edit6.text:=IntToStr(DBMultiImage1.Bnumcolors);
  322.   Edit7.text:=DBMultiImage1.Bcompression;
  323.   Edit8.text:=IntToStr(DBMultiImage1.BSize)+ ' bytes';
  324. end;
  325. {---------------------------------------------------------------------}
  326.  
  327. procedure TBlobForm1.BitBtn1Click(Sender: TObject);
  328. begin
  329.  {load a image file in the current blob using Thumbnail previews}
  330.  ThumbPreview1.PreviewsDir:=ExtractFilePath(Application.Exename);
  331.  ThumbPreview1.DataFileDir:=ExtractFilePath(Application.Exename);
  332.  If ThumbPreview1.Execute Then begin
  333.    {Place table in edit mode}
  334.    Table1.Edit;
  335.    {Load the image from file into the blob}
  336.    DBMultiImage1.LoadFromFile(ThumbPreview1.FileName);
  337.    {Post the blob}
  338.    Table1.Post;
  339.    {reset the gauge to 0}
  340.    Gauge1.Progress:=0;
  341.  end;
  342. end;
  343. {---------------------------------------------------------------------}
  344.  
  345. procedure TBlobForm1.BitBtn2Click(Sender: TObject);
  346. var temp : string;
  347. begin
  348.  {Save the current blob to a jpeg, pcx, gif or Bmp  file.  The SaveToFile
  349.  will save it as stored in the blob. (no conversion is done here)
  350.  Use SaveToFileAsBMP or SaveToFileAsJpeg to Convert to one another}
  351.  
  352.  {get the extension (filetype) of the stored blob}
  353.  {GetInfoAndType returns the extension of the blob stored}
  354.  if not table1.active then exit;
  355.  temp:=DBMultiImage1.GetInfoAndType;
  356.  
  357.  if temp = 'GIF' then begin
  358.  {set SaveDialog filter to display gif's only}
  359.   SaveDialog1.filter:='GIF files|*.GIF';
  360.  
  361.   {set SaveDialog Default extension}
  362.   SaveDialog1.DefaultExt:='GIF';
  363.  end else
  364.  
  365.  if temp = 'PCX' then begin
  366.  {set SaveDialog filter to display pcx's only}
  367.   SaveDialog1.filter:='PCX files|*.PCX';
  368.  
  369.   {set SaveDialog Default extension}
  370.   SaveDialog1.DefaultExt:='PCX';
  371.  end else
  372.  
  373.  if temp = 'JPG' then begin
  374.  {set SaveDialog filter to display jpeg's only}
  375.   SaveDialog1.filter:='Jpeg files|*.JPG';
  376.  
  377.   {set SaveDialog Default extension}
  378.   SaveDialog1.DefaultExt:='JPG';
  379.  end else
  380.  
  381.  if temp = 'BMP' then begin
  382.  {set SaveDialog filter to display bmp's only}
  383.   SaveDialog1.filter:='BMP files|*.BMP';
  384.   {set SaveDialog Default extension}
  385.   SaveDialog1.DefaultExt:='BMP';
  386.  end;
  387.  
  388.  {save it to file as stored in blob}
  389.  If SaveDialog1.Execute Then
  390.    DBMultiImage1.SaveToFile(SaveDialog1.FileName);
  391.  {reset the gauge to 0}
  392.  Gauge1.Progress:=0;
  393. end;
  394. {---------------------------------------------------------------------}
  395.  
  396.  
  397. procedure TBlobForm1.ResolutionClick(Sender: TObject);
  398. begin
  399.  
  400.  {Set resolution and dither the image}
  401.  
  402.  if RadioButton1.Checked then begin
  403.  {Set resolution to 16 colors}
  404.   DBMultiImage1.ImageReadRes:=lColor16;
  405.  {Set dither }
  406.   DBMultiImage1.ImageDither:=True;
  407.  end else
  408.  
  409.  if RadioButton2.Checked then begin
  410.  {Set resolution to 256 colors}
  411.   DBMultiImage1.ImageReadRes:=lColor256;
  412.  {Set dither }
  413.   DBMultiImage1.ImageDither:=True;
  414.  end else
  415.  
  416.  if RadioButton3.Checked then begin
  417.   {Set resolution to true color}
  418.   DBMultiImage1.ImageReadRes:=lColorTrue;
  419.  {Set dither }
  420.   DBMultiImage1.ImageDither:=False;
  421.  end;
  422.  
  423.  if resAuto.Checked then begin
  424.   {Set resolution to true color}
  425.   DBMultiImage1.ImageReadRes:=lAutomatic;
  426.  {Set dither }
  427.   DBMultiImage1.ImageDither:=True;
  428.  end;
  429.  
  430.  
  431.  
  432.  {Reload the image }
  433.  Table1.Refresh;
  434.  
  435.  {reset the gauge to 0}
  436.  Gauge1.Progress:=0;
  437. end;
  438. {---------------------------------------------------------------------}
  439.  
  440.  
  441. procedure TBlobForm1.BitBtn4Click(Sender: TObject);
  442. begin
  443.   {Check to see if image is there}
  444.   if DBMultiImage1.Picture.Bitmap <> nil then
  445.    {Copy the image to the clipboard}
  446.     DBMultiImage1.CopyToClipboard;
  447.    {reset the gauge to 0}
  448.    Gauge1.Progress:=0;
  449. end;
  450. {---------------------------------------------------------------------}
  451.  
  452. procedure TBlobForm1.BitBtn5Click(Sender: TObject);
  453. {Paste image from clipboard}
  454. begin
  455.    {does the clipboard has the right format?}
  456.    if Clipboard.HasFormat(CF_PICTURE) then
  457.    {Yep it does. Paste image from clipboard}
  458.    DBMultiImage1.PastefromClipboard;
  459.  
  460.    {reset the gauge to 0}
  461.    Gauge1.Progress:=0;
  462. end;
  463. {---------------------------------------------------------------------}
  464.  
  465. procedure TBlobForm1.Timer1Timer(Sender: TObject);
  466. begin
  467.   {En/Disable Paste Button if clipboard has format}
  468.   BitBtn5.Enabled:=Clipboard.HasFormat(CF_PICTURE);
  469.   {Enable/disable certain buttons}
  470.   {Button is only then enabled if table is active}
  471.   BitBtn1.Enabled:=Table1.Active;
  472.   {Button is only then enabled if table is active}
  473.   BitBtn2.Enabled:=Table1.Active;
  474.   {Button is only then enabled if table is active}
  475.   BitBtn4.Enabled:=Table1.Active;
  476.   {Button is only then enabled if table is active}
  477.   BitBtn6.Enabled:=Table1.Active;
  478.   {Button is only then enabled if table is active}
  479.   BitBtn7.Enabled:=Table1.Active;
  480.   {Button is only then enabled if table is active}
  481.   BitBtn8.Enabled:=Table1.Active;
  482.   {Button is only then enabled if table is active}
  483.   BitBtn9.Enabled:=Table1.Active;
  484.   {Button is only then enabled if table is active}
  485.   BitBtn11.Enabled:=Table1.Active;
  486.   {Button is only then enabled if table is active}
  487.   BitBtn13.Enabled:=Table1.Active;
  488.   {Box is only then visible if table is active and field is in edit state}
  489.   GroupBox2.Visible:=Table1.Active and (DataSource1.State in [dsEdit, dsInsert]);
  490.   {Box is only then visible if table is active and field is in edit state and update is in jpeg mode}
  491.   GroupBox3.Visible:=Table1.Active and RadioButton4.Checked and (DataSource1.State in [dsEdit, dsInsert]);
  492.   {Rotating and flipping can only be done while Stretching}
  493.   if (StretchRatioCheckBox.Checked) or (StretchCheckBox.Checked) then begin
  494.      RotateImageBtn.Enabled:=True;
  495.      FlipImagetBtn.Enabled:=True;
  496.      BitBtn17.Enabled:=True;
  497.      BitBtn18.Enabled:=True;
  498.      BitBtn19.Enabled:=True;
  499.   end else begin
  500.      RotateImageBtn.Enabled:=False;
  501.      FlipImagetBtn.Enabled:=False;
  502.      BitBtn17.Enabled:=False;
  503.      BitBtn18.Enabled:=False;
  504.      BitBtn19.Enabled:=False;
  505.   end;
  506.  
  507. end;
  508. {---------------------------------------------------------------------}
  509.  
  510. procedure TBlobForm1.BitBtn6Click(Sender: TObject);
  511. begin
  512.  {Append a record and store an image file into the blob}
  513.  If OpenDialog1.Execute Then begin
  514.    {Place table in edit mode}
  515.    Table1.Append;
  516.    {Load the image from file into the blob}
  517.    DBMultiImage1.LoadFromFile(OpenDialog1.FileName);
  518.    {Post the blob}
  519.    Table1.Post;
  520.    {reset the gauge to 0}
  521.    Gauge1.Progress:=0;
  522.  end;
  523. end;
  524. {---------------------------------------------------------------------}
  525.  
  526. procedure TBlobForm1.BitBtn3Click(Sender: TObject);
  527. begin
  528. {open the table}
  529.       If OpenDialog2.execute then begin
  530.         Table1.Active:=False;
  531.         Table1.DataBaseName:=ExtractFilePath(OpenDialog2.FileName);
  532.         Table1.TableName:=OpenDialog2.FileName;
  533.         Table1.Active:=True;
  534.       end;
  535. end;
  536. {---------------------------------------------------------------------}
  537.  
  538. procedure TBlobForm1.RadioButton4Click(Sender: TObject);
  539. begin
  540.  {If the image data is changed save the blob to a jpeg blob}
  541.  DBMultiImage1.UpdateASJpg:=RadioButton4.Checked;
  542.  
  543.  {Hide or show the jpeg update/save options}
  544.  GroupBox3.Visible:=RadioButton4.Checked;
  545. end;
  546. {---------------------------------------------------------------------}
  547.  
  548. procedure TBlobForm1.BitBtn7Click(Sender: TObject);
  549.  {save or convert the blob to a BMP file}
  550.  {make sure that the blob is displayed before saving to file}
  551. begin
  552.   {set SaveDialog filter to display bmp's only}
  553.   SaveDialog2.filter:='BMP files|*.BMP';
  554.  
  555.   {set SaveDialog Default extension}
  556.   SaveDialog2.DefaultExt:='BMP';
  557.  
  558.   if SaveDialog2.Execute then
  559.   {Save it}
  560.   DBMultiImage1.SaveToFileAsBMP(SaveDialog2.Filename);
  561.  
  562.   {reset the gauge to 0}
  563.   Gauge1.Progress:=0;
  564. end;
  565. {---------------------------------------------------------------------}
  566.  
  567. procedure TBlobForm1.BitBtn8Click(Sender: TObject);
  568.  {save or convert the blob to a Jpeg file}
  569.  {make sure that the blob is displayed before saving to file}
  570. begin
  571.   {set SaveDialog filter to display jpeg's only}
  572.   SaveDialog2.filter:='Jpeg files|*.JPG';
  573.  
  574.   {set SaveDialog Default extension}
  575.   SaveDialog2.DefaultExt:='JPG';
  576.  
  577.   if SaveDialog2.Execute then
  578.   {Save it}
  579.   DBMultiImage1.SaveToFileAsJpg(SaveDialog2.Filename);
  580.  
  581.   {reset the gauge to 0}
  582.   Gauge1.Progress:=0;
  583. end;
  584. {---------------------------------------------------------------------}
  585.  
  586. procedure TBlobForm1.SpinEdit2Change(Sender: TObject);
  587. begin
  588.   {Set the smooth of the jpeg to save or upate a blob}
  589.   DBMultiImage1.JPegSaveSmooth:=SpinEdit2.Value;
  590. end;
  591. {---------------------------------------------------------------------}
  592.  
  593. procedure TBlobForm1.SpinEdit1Change(Sender: TObject);
  594. begin
  595.   {Set the quality of the jpeg to save or upate a blob}
  596.   DBMultiImage1.JPegSaveQuality:=SpinEdit1.Value;
  597. end;
  598. {---------------------------------------------------------------------}
  599.  
  600. procedure TBlobForm1.BitBtn9Click(Sender: TObject);
  601. begin
  602.   if PrintDialog1.execute then begin
  603.   {Initialize the height spinedit of the printsize dialog box}
  604.    Printersize.HeigthSpinEdit.Value:=DBMultiImage1.Picture.Height;
  605.    {Initialize the width spinedit of the printsize dialog box}
  606.    Printersize.WidthSpinEdit.Value:=DBMultiImage1.Picture.Width;
  607.    {Show it}
  608.    Printersize.ShowModal;
  609.    if Printersize.Modalresult = mrok then
  610.  
  611.     {print TMultiImage}
  612.      DBMultiImage1.PrintMultiImage(0,0,Printersize.WidthSpinEdit.Value,Printersize.HeigthSpinEdit.Value);
  613.  
  614.    {Hide it if done}
  615.    Printersize.hide;
  616.   end;
  617. end;
  618. {---------------------------------------------------------------------}
  619.  
  620. procedure TBlobForm1.BitBtn11Click(Sender: TObject);
  621. begin
  622.   {copy DB Blob image to fullscreen image}
  623.   FullSlide.MultiImage1.Picture.Graphic:=DBMultiImage1.Picture.Graphic;
  624.   {show the image fulscreen}
  625.   FullSlide.showmodal;
  626. end;
  627. {---------------------------------------------------------------------}
  628.  
  629. procedure TBlobForm1.BitBtn12Click(Sender: TObject);
  630. {about box}
  631. begin
  632. {Copy the image to the image of he about box}
  633.  AboutBox.Image1.Picture.Graphic:=DBMultiImage1.Picture.Graphic;
  634. {show the about box}
  635.  AboutBox.showmodal;
  636. end;
  637. {---------------------------------------------------------------------}
  638.  
  639. procedure TBlobForm1.BitBtn13Click(Sender: TObject);
  640. begin
  641.     {Place the Database in append mode}
  642.     Table1.Append;
  643.     {Create a New Message}
  644.     If DBMultiImage1.CreateMessage then
  645.     {Post or cancel that thing}
  646.       Table1.Post
  647.     else
  648.       Table1.Cancel;
  649. end;
  650. {---------------------------------------------------------------------}
  651.  
  652. procedure TBlobForm1.RadioButton5Click(Sender: TObject);
  653. begin
  654.  {If the image data is changed save the blob to Bmp blob}
  655.  DBMultiImage1.UpdateASBMP:=RadioButton5.Checked;
  656.  
  657.  {Hide or show the update/save options}
  658.  GroupBox3.Visible:=RadioButton4.Checked;
  659. end;
  660. {---------------------------------------------------------------------}
  661.  
  662. procedure TBlobForm1.RadioButton6Click(Sender: TObject);
  663. begin
  664.  {If the image data is changed save the blob to a GIF blob}
  665.  DBMultiImage1.UpdateASGif:=RadioButton4.Checked;
  666.  
  667.  {Hide or show the jpeg update/save options}
  668.  GroupBox3.Visible:=RadioButton4.Checked;
  669. end;
  670. {---------------------------------------------------------------------}
  671.  
  672. procedure TBlobForm1.RadioButton7Click(Sender: TObject);
  673. begin
  674.  {If the image data is changed save the blob to a PCX blob}
  675.  DBMultiImage1.UpdateASPcx:=RadioButton4.Checked;
  676.  
  677.  {Hide or show the jpeg update/save options}
  678.  GroupBox3.Visible:=RadioButton4.Checked;
  679. end;
  680. {---------------------------------------------------------------------}
  681.  
  682. procedure TBlobForm1.RadioButton8Click(Sender: TObject);
  683. begin
  684.  {If the image data is changed save the blob to a TIF blob}
  685.  DBMultiImage1.UpdateASTif:=RadioButton8.Checked;
  686.  
  687.  {Hide or show the jpeg update/save options}
  688.  GroupBox3.Visible:=RadioButton4.Checked;
  689. end;
  690. {---------------------------------------------------------------------}
  691.  
  692. procedure TBlobForm1.RadioButton9Click(Sender: TObject);
  693. begin
  694.  {If the image data is changed save the blob to a PNG blob}
  695.  DBMultiImage1.UpdateASPng:=RadioButton4.Checked;
  696.  
  697.  {Hide or show the jpeg update/save options}
  698.  GroupBox3.Visible:=RadioButton4.Checked;
  699. end;
  700. {---------------------------------------------------------------------}
  701.  
  702. procedure TBlobForm1.BitBtn14Click(Sender: TObject);
  703.  {save or convert the blob to a GIF file}
  704.  {make sure that the blob is displayed before saving to file}
  705. begin
  706.   {set SaveDialog filter to display bmp's only}
  707.   SaveDialog2.filter:='GIF files|*.GIF';
  708.  
  709.   {set SaveDialog Default extension}
  710.   SaveDialog2.DefaultExt:='GIF';
  711.  
  712.   if SaveDialog2.Execute then
  713.   {Save it}
  714.   DBMultiImage1.SaveToFileAsGIF(SaveDialog2.Filename);
  715.  
  716.   {reset the gauge to 0}
  717.   Gauge1.Progress:=0;
  718. end;
  719. {---------------------------------------------------------------------}
  720.  
  721. procedure TBlobForm1.BitBtn15Click(Sender: TObject);
  722.  {save or convert the blob to a PCX file}
  723.  {make sure that the blob is displayed before saving to file}
  724. begin
  725.   {set SaveDialog filter to display bmp's only}
  726.   SaveDialog2.filter:='PCX files|*.PCX';
  727.  
  728.   {set SaveDialog Default extension}
  729.   SaveDialog2.DefaultExt:='PCX';
  730.  
  731.   if SaveDialog2.Execute then
  732.   {Save it}
  733.   DBMultiImage1.SaveToFileAsBMP(SaveDialog2.Filename);
  734.  
  735.   {reset the gauge to 0}
  736.   Gauge1.Progress:=0;
  737. end;
  738. {---------------------------------------------------------------------}
  739.  
  740. procedure TBlobForm1.BitBtn16Click(Sender: TObject);
  741.  {save or convert the blob to a PNG file}
  742.  {make sure that the blob is displayed before saving to file}
  743. begin
  744.   {set SaveDialog filter to display bmp's only}
  745.   SaveDialog2.filter:='PNG files|*.PNG';
  746.  
  747.   {set SaveDialog Default extension}
  748.   SaveDialog2.DefaultExt:='PNG';
  749.  
  750.   if SaveDialog2.Execute then
  751.   {Save it}
  752.   DBMultiImage1.SaveToFileAsBMP(SaveDialog2.Filename);
  753.  
  754.   {reset the gauge to 0}
  755.   Gauge1.Progress:=0;
  756. end;
  757. {---------------------------------------------------------------------}
  758.  
  759. procedure TBlobForm1.BitBtn20Click(Sender: TObject);
  760.  {save or convert the blob to a TIF file}
  761.  {make sure that the blob is displayed before saving to file}
  762. begin
  763.   {set SaveDialog filter to display bmp's only}
  764.   SaveDialog2.filter:='TIF files|*.TIF';
  765.  
  766.   {set SaveDialog Default extension}
  767.   SaveDialog2.DefaultExt:='TIF';
  768.  
  769.   if SaveDialog2.Execute then
  770.   {Save it}
  771.   DBMultiImage1.SaveToFileAsTIF(SaveDialog2.Filename);
  772.  
  773.   {reset the gauge to 0}
  774.   Gauge1.Progress:=0;
  775. end;
  776. {---------------------------------------------------------------------}
  777.  
  778. procedure TBlobForm1.BitBtn10Click(Sender: TObject);
  779. begin
  780.     {Place the Database in append mode}
  781.     Table1.Append;
  782.     {Create a New Credit Message}
  783.     If DBMultiImage1.CreateCreditMessage then
  784.     {Post or cancel that thing}
  785.       Table1.Post
  786.     else
  787.       Table1.Cancel;
  788. end;
  789. {---------------------------------------------------------------------}
  790.  
  791. {---------------------------------------------------------------------}
  792.  
  793. procedure TBlobForm1.RotateImageBtnClick(Sender: TObject);
  794. begin
  795.   DBMultiImage1.RotateImage;
  796. end;
  797. {---------------------------------------------------------------------}
  798.  
  799. procedure TBlobForm1.FlipImagetBtnClick(Sender: TObject);
  800. begin
  801.   DBMultiImage1.FlipImage;
  802. end;
  803. {---------------------------------------------------------------------}
  804.  
  805. procedure TBlobForm1.BitBtn19Click(Sender: TObject);
  806. begin
  807.  {Reset image to the default}
  808.  DBMultiImage1.ResetImage;
  809. end;
  810. {---------------------------------------------------------------------}
  811.  
  812. procedure TBlobForm1.BitBtn17Click(Sender: TObject);
  813. begin
  814.  DBMultiImage1.ZoomOut;
  815. end;
  816. {---------------------------------------------------------------------}
  817.  
  818. procedure TBlobForm1.BitBtn18Click(Sender: TObject);
  819. begin
  820.  DBMultiImage1.ZoomIn;
  821. end;
  822. {---------------------------------------------------------------------}
  823.  
  824. procedure TBlobForm1.BitBtn21Click(Sender: TObject);
  825. begin
  826.    {Scan an image using a twain scanner}
  827.    DBMultiImage1.ScanImage(Handle);
  828. end;
  829. {---------------------------------------------------------------------}
  830.  
  831. procedure TBlobForm1.DBMultiImage1MouseDown(Sender: TObject;
  832.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  833. begin
  834.   if not StretchCheckBox.Checked then Exit;
  835.   bLeftDown := false;
  836.   if button = mbLeft then begin
  837.     DBMultiImage1.ResetImage;
  838.     bLeftDown := true;
  839.     pointStart.X := X;
  840.     pointStart.Y := Y;
  841.     pointEnd.X := X;
  842.     pointEnd.Y := Y;
  843.   end;
  844. end;
  845. {---------------------------------------------------------------------}
  846.  
  847. procedure TBlobForm1.DBMultiImage1MouseMove(Sender: TObject;
  848.   Shift: TShiftState; X, Y: Integer);
  849. begin
  850.   if not bLeftDown then exit;
  851.   DrawRubberband;
  852.   pointEnd.x := X;
  853.   pointEnd.y := Y;
  854.   DrawRubberband;
  855. end;
  856. {---------------------------------------------------------------------}
  857.  
  858. procedure TBlobForm1.DBMultiImage1MouseUp(Sender: TObject;
  859.   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  860. begin
  861.   if not bLeftDown then exit;
  862.   DrawRubberband;
  863.   bLeftDown := false;
  864.   pointEnd.X := X;
  865.   pointEnd.Y := Y;
  866.   {Zoom , flip or rotate image}
  867.   DBMultiImage1.TransformImage(Rect(pointStart.X, pointStart.Y, pointEnd.X, pointEnd.Y));
  868. end;
  869. {---------------------------------------------------------------------}
  870.  
  871. procedure TBlobForm1.DrawRubberband;
  872. begin
  873.   SetROP2(DBMultiImage1.Canvas.handle, R2_NOT);
  874.   DBMultiImage1.Canvas.moveto(pointStart.x, pointStart.y);
  875.   DBMultiImage1.Canvas.lineto(pointStart.x, pointEnd.y);
  876.   DBMultiImage1.Canvas.lineto(pointEnd.x, pointEnd.y);
  877.   DBMultiImage1.Canvas.lineto(pointEnd.x, pointStart.y);
  878.   DBMultiImage1.Canvas.lineto(pointStart.x, pointStart.y);
  879. end;
  880. {---------------------------------------------------------------------}
  881.  
  882. procedure TBlobForm1.DBNavigator1Click(Sender: TObject;
  883.   Button: TNavigateBtn);
  884. begin
  885.   DBMultiImage1.ResetImage;
  886. end;
  887. {---------------------------------------------------------------------}
  888.  
  889. procedure TBlobForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  890. begin
  891.  {Turn off the OnIdle}
  892.  Application.OnIdle:=Nil;
  893.  {Unregister the callback function to the VCL/DLL}
  894.  TPDBMultiImageCallBack:=Nil;
  895.  {Free the printer size form}
  896.  Printersize.free;
  897.  BlobForm1 := Nil;
  898.  Action := caFree;
  899. end;
  900.  
  901. end.
  902.